package exercise6;


public class Exercise13_06 {
    public static void main(String []args){

        ComparableCircle circle1=new ComparableCircle(2);
        ComparableCircle circle2=new ComparableCircle(3);

        System.out.println("较大的圆的半径是"+ComparableCircle.max(circle1,circle2).r);
    }
}

class ComparableCircle extends Circle1 implements Comparable<ComparableCircle>{


    public ComparableCircle(double r) {
        super(r);
    }

    public double getArea(){
        return Math.PI*Math.pow(r,2);
    }

    @Override
    public int compareTo(ComparableCircle o){
        return Double.compare(getArea(),o.getArea());
    }

    public static ComparableCircle max(ComparableCircle o1,ComparableCircle o2){
        if (o1.compareTo(o2)>0){
            return o1;
        }
        else{
            return o2;
        }
    }

}

class Circle1{
    double r;
    public Circle1(double r){
        this.r=r;
    }
}